//
//  EAGLView.h
//  AppleCoder-OpenGLES-00
//
//  Created by Simon Maurice on 18/03/09.
//  Copyright Simon Maurice 2009. All rights reserved.
//


#import <UIKit/UIKit.h>
#import <OpenGLES/EAGL.h>
#import <OpenGLES/ES2/gl.h>
#import <OpenGLES/ES2/glext.h>

@interface EAGLView : UIView
{
@private
    // The pixel dimensions of the CAEAGLLayer.
    GLint backingWidth;
    GLint backingHeight;
    
    EAGLContext *context;
    
    /* OpenGL names for the renderbuffer and framebuffers used to render to this view */
    GLuint viewRenderbuffer, viewFramebuffer, msaaFramebuffer, msaaRenderbuffer, msaaDepthbuffer;
    
    /* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */
    GLuint depthRenderbuffer;
    // The pointer to the lesson which we're rendering
    
    // Did we already initialize our lesson?
    BOOL applicationIsInitialized;
    //   GLuint texture[1];
}

// The OpenGL context as a property (has autogenerated getter and setter)
@property (nonatomic, retain) EAGLContext *context;
@property (nonatomic, assign) NSTimeInterval animationInterval;
@property (nonatomic, assign) NSTimer *animationTimer;
// Configuration setters


//if we want OpenGL to repaint with the screens refresh rate, we use this render loop
- (void) startRenderLoop;
- (void) stopRenderLoop;
- (void) rotateWithX:(float)x Y:(float)y;
- (void) moveWithX:(float)x Y:(float)y;
- (void) scale:(float)s;

- (void) drawFrame;
- (void) reset;
- (BOOL) loadModel:(NSString*)path;

// for debug
- (void) setCameraPositionWithX:(float)x Y:(float)y Z:(float) z;
- (void) setLigthDirectionWithX:(float)x Y:(float)y Z:(float) z;
- (void) setAmbientColorWithX:(unsigned char)x Y:(unsigned char)y Z:(unsigned char) z;
- (void) setDiffuseColorWithX:(unsigned char)x Y:(unsigned char)y Z:(unsigned char) z;

@end


